﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Admin.CYT369.Com.DAL.Domains.Apps
{
    /// <summary>
    /// 系统功能菜单
    /// </summary>
    public class SystemMenu: BaseObject<int>
    {
        public int ParentID { get; set; }

        /// <summary>
        /// 功能菜单编号
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 功能菜单名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 说明
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// 目标地址
        /// </summary>
        public string Url { get; set; }


        public string Target { get; set; }

        /// <summary>
        /// 图标样式
        /// </summary>
        public string IconClassName { get; set; }

        /// <summary>
        /// 排序号
        /// </summary>
        public int Sequence { get; set; }


        /// <summary>
        /// 是否支持折叠
        /// </summary>
        public bool CanFold { get; set; }

        /// <summary>
        /// 是否展开
        /// </summary>
        public bool Expanded { get; set; }

        /// <summary>
        /// 是否启用
        /// </summary>
        public bool Enable { get; set; }

        /// <summary>
        /// 是否删除
        /// </summary>
        public bool Deleted { get; set; }


        [System.Text.Json.Serialization.JsonIgnore]
        public virtual ICollection<SystemMenu> SubMenus { get; set; } = new HashSet<SystemMenu>();


        [System.Text.Json.Serialization.JsonIgnore]
        public SystemMenu ParentMenu { get; set; }

        #region view modles
        public int id {
            get { return this.Id; }
            set { this.Id = value; }
        }
        public string text {
            get { return this.Name; }
            set { this.Name = value; }
        }
        public string iconCls {
            get { return this.IconClassName; }
            set { this.IconClassName = value; }
        }
        public string state { get; set; } = string.Empty;
        public bool selected { get; set; }
        public ICollection<SystemMenu> children {
            get {
                if (this.SubMenus != null)
                {
                    if (this.SubMenus.Count > 0)
                    {
                        return this.SubMenus;
                    }
                }

                return null;
            }
            set { this.SubMenus = value; }
        }
        #endregion

    }

}
